import asyncio

async def fetch_data(url):
    await asyncio.sleep(1)
    return f"Data from {url}"

async def main():
    # 将协程封装为Task对象
    task = loop.create_task(fetch_data("https://api.example.com"))
    # 等待任务完成
    result = await task
    print(result)

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())  # 运行主协程[4,5](@ref)
    loop.close()